import 'package:OASys/entity/EventVo.dart';
import 'package:OASys/httpConfig/DioManager.dart';
import 'package:OASys/httpConfig/ErrorEntity.dart';
import 'package:OASys/httpConfig/NWMethod.dart';

class EventApi {
  void getInfo(int id,
      {Function(EventVo) success, Function(ErrorEntity) error}) {
    DioManager().request<EventVo>(
      NWMethod.GET,
      "/front/event/get/$id",
      success: success,
      error: error,
    );
  }

  void save(EventVo info,
      {Function(String) success, Function(ErrorEntity) error}) {
    DioManager().request<String>(
      NWMethod.POST,
      "/front/event/save",
      params: info.toJson(),
      success: success,
      error: error,
    );
  }

  void list(int page, int limit,
      {EventVo andQuery,
      Function(List<EventVo>) success,
      Function(ErrorEntity) error}) {
    DioManager().requestList<EventVo>(
      NWMethod.POST,
      "/front/event/list",
      params: {
        "page": page,
        "limit": limit,
        "andQuery": andQuery,
      },
      success: success,
      error: error,
    );
  }

  void checkList(int page, int limit,
      {EventVo andQuery,
      Function(List<EventVo>) success,
      Function(ErrorEntity) error}) {
    DioManager().requestList<EventVo>(
      NWMethod.POST,
      "/front/event/checkList",
      params: {
        "page": page,
        "limit": limit,
        "andQuery": andQuery,
      },
      success: success,
      error: error,
    );
  }

  void checkedList(int page, int limit,
      {EventVo andQuery,
      Function(List<EventVo>) success,
      Function(ErrorEntity) error}) {
    DioManager().requestList<EventVo>(
      NWMethod.POST,
      "/front/event/checkedList",
      params: {
        "page": page,
        "limit": limit,
        "andQuery": andQuery,
      },
      success: success,
      error: error,
    );
  }

  void remove(int id, {Function(String) success, Function(ErrorEntity) error}) {
    DioManager().request<String>(
      NWMethod.DELETE,
      "/front/event/remove/$id",
      success: success,
      error: error,
    );
  }

  void checkSuccess(int id, String content,
      {Function(String) success, Function(ErrorEntity) error}) {
    DioManager().request<String>(
      NWMethod.POST,
      "/front/event/checkSuccess",
      params: {
        "id": id,
        "content": content,
      },
      success: success,
      error: error,
    );
  }

  void checkFail(int id, String content,
      {Function(String) success, Function(ErrorEntity) error}) {
    DioManager().request<String>(
      NWMethod.POST,
      "/front/event/checkFail",
      params: {
        "id": id,
        "content": content,
      },
      success: success,
      error: error,
    );
  }
}
